package com.yangguang.huahui.ui.adapters;

import android.content.Context;
import android.widget.ImageView;

import com.yangguang.huahui.R;
import com.yangguang.huahui.entity.AttentionList;
import com.yangguang.huahui.listadpter.CommonAdapter;
import com.yangguang.huahui.listadpter.ViewHolder;
import com.yangguang.huahui.utils.CommonUtil;
import com.yangguang.huahui.utils.ImageLoader;

import java.util.Calendar;
import java.util.List;

/**
 * Created by Administrator on 2017/3/7.
 */

public class HomeListAdapter extends CommonAdapter<AttentionList.ListBean>{
    public HomeListAdapter(Context context, List<AttentionList.ListBean> data, int layoutId) {
        super(context, data, layoutId);
    }

    @Override
    public void convert(ViewHolder helper, AttentionList.ListBean listBean) {
        ImageLoader.load(mContext, listBean.getCarousel(), (ImageView) helper.getView(R.id.iv_miaomu));
        helper.setText(R.id.tv_title, listBean.getGoods_title());
        helper.setText(R.id.tv_price, listBean.getPrice());
        helper.setText(R.id.tv_source, listBean.getSource_of_supply_name());
        if (!CommonUtil.isNull(listBean.getRelease_time())) {
            helper.setText(R.id.tv_date, "发布时间：" + CommonUtil.longToTime(Long.parseLong(listBean.getRelease_time()+"000"), Calendar.DATE));
        }else {
            helper.setText(R.id.tv_date, "发布时间：");
        }
    }
    public void setNewData(List<AttentionList.ListBean> data) {
        this.mDatas = data;
        notifyDataSetChanged();
    }
}
